﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ANLP.Sample;
using ANLP.Sample.Expressions;

namespace Turtle
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            Parser parser = new Parser(new Lexer());
            Program p = (Program)parser.Parse("up down move 10,5 up");
            Treat(p);
        }

        private void Treat(Statement statement)
        {
            switch (statement.StatementType)
            {
                case Statements.Up:
                    output.Text += "Up"+Environment.NewLine;
                    break;
                case Statements.Down:
                    output.Text += "Down" + Environment.NewLine;
                    break;
                case Statements.Move:
                    output.Text += "Move " + ((MoveStatement)statement).X + ", " + ((MoveStatement)statement).Y + Environment.NewLine;
                    break;
                case Statements.Block:
                    foreach (Statement s in ((BlockStatement)statement).Statements)
                        Treat(s);
                    break;
                default:
                    break;
            }
        }
    }
}
